<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>5_1_2-定义组件</title>
</head>

<body>


  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <div id="Application">
    <my-alert></my-alert>
    <my-alert></my-alert>

  </div>
  <script>
    const App = Vue.createApp({});


    const alertComponent = {
      setup() {
        let msg = Vue.ref('警告标识')
        let count = Vue.ref(0)
        const click = () => {
          count.value++;
        }
        return {
          msg,
          count,
          click
        }
      },
      template: '<div>简单还有趣<button @click="click">{{msg+count}}</button></div>'
    };
    App.component("my-alert", alertComponent);


    //挂载
    App.mount("#Application");
  </script>
</body>

</html>